import { RouteRecordRaw } from "vue-router";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import UserManageView from "@/views/user/UserManageView.vue";
import UserProfileView from "@/views/user/UserProfileView.vue";
import PostList from "@/views/post/PostList.vue";
import PostEdit from "@/views/post/PostEdit.vue";
import PostDetail from "@/views/post/PostDetail.vue";
import PostView from "@/views/post/PostView.vue";
import QuestionsSubmissionsDetail from "@/views/question/QuestionsSubmissionsDetail.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
      {
        path: "/user/profile",
        name: "个人主页",
        component: UserProfileView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/",
    name: "主页",
    component: QuestionsView,
    meta: {
      title: "花都判题",
    },
  },
  {
    path: "/question_submit",
    name: "浏览题目提交",
    component: QuestionSubmitView,
  },
  {
    path: "/submissions/detail/:id",
    name: "提交详情",
    props: true,
    component: QuestionsSubmissionsDetail,
    meta: {
      hideInMenu: true,
      access: ACCESS_ENUM.USER,
      title: "提交详情",
    },
  },
  {
    path: "/view/question/:id",
    name: "在线做题",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/update/question",
    name: "更新题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/manage/question/",
    name: "题目管理",
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/manage/user",
    name: "用户管理",
    component: UserManageView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/post/list",
    name: "管理帖子",
    component: PostList,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/post/create",
    name: "创建帖子",
    component: PostEdit,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/post/edit/:id",
    name: "编辑帖子",
    component: PostEdit,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/post/detail/:id",
    name: "帖子细节",
    component: PostDetail,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/posts",
    name: "帖子广场",
    component: PostView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
];
